home *** CD-ROM | disk | FTP | other *** search
- /*============================================================
-
- Snow demo program
-
- ============================================================*/
-
- #include "N_Library.h"
-
- void Main_Process(void);
- void Key_Process(void);
- WindowPtr CreateWindow(Str255 name);
-
- #define WindowSizeX 640
- #define WindowSizeY 480
-
- short NewWindowX;
- short NewWindowY;
- short Data_Rsrc = 0;
- long routine_step = 0;
- long wait;
- short S1_X[1024];
- short S1_Y[1024];
- unsigned short S1_D[1024];
- short r = 0,rs=0;
- short lx=640;
- short speed = -3;
- Boolean q = false;
- Boolean kb=false;
- EventRecord theEvent;
- short Snd_List0[] = {1000,1001,1002,0};
- short Music1[] = { 1002,-1 };
-
- void main(void)
- {
- WindowPtr window;
- short i;
-
- ToolboxInit();
- ColorCheck();
- HideMenuBar();
- window = CreateWindow("\pPUSH 'Q' TO QUIT");
- N_Window_Set(window,NewWindowX,NewWindowY,WindowSizeX,WindowSizeY);
- N_Sp_Make(640,480);
- N_Cel_Make(150000);
- Open_Resource_File(128,1,&Data_Rsrc);
- // Set Kanban Sprites <Sprites & Cel> (Sprite 256)
- N_Sprite_Set(130,50,12,16,1,13,4,0); //Set font sprites (Sp50-)
- Through_Col = 0xff;
- N_Sprite_Set(200,256,216,88,0,1,1,0); //wood panel (Sp 256)
- // Set Snow Sprites (Sprite 30-46)
- N_Sprite_Set(404,30,32,32,0,1,1,2); //snow (2=zoom out mode,16lev) (Sp 30-46)
- N_Sprite_Set(419,46,8,8,0,1,1,0);
- Through_Col = 0x00;
- N_Sprite_Set(132,100,25,26,1,6,1,0); //button(Sp 100-105)
- N_Sprite_Set(133,110,208,120,0,1,1,0); //control panel(Sp 110)
- N_Font_Set(0,0x80000000+50,0,0x80000000+76,0x80000000+87); //Font Set 0
- N_Pict_Draw(131,0,0,(GrafPtr)SP_off,true); //draw background on SP_Off
- N_Sound_Load(&Snd_List0[0]); //set sounds
- N_Music_Set(1,&Music1[0]); //set Music 1
- N_Music_Play(1); //play Music 1
-
- // Button Set-up
- N_Button_Set(0,0,1,10,404,512,0x80000000+100,0x80000000+101,1000,1001); //Q Button
- N_Button_Set(0,1,1,40,404,512,0x80000000+102,0x80000000+103,1000,1001); //C Button
- N_Button_Set(0,2,1,130,364,40,0x80000000+104,0x80000000+105,1000,1001); //up Button
- N_Button_Set(0,3,1,130,442,40,0x80000000+104,0x80000000+105,1000,1001); //down Button
- N_Button_Set(0,4,1,93,404,40,0x80000000+104,0x80000000+105,1000,1001); //left Button
- N_Button_Set(0,5,1,167,404,40,0x80000000+104,0x80000000+105,1000,1001); //right Button
-
- Close_Resource_File(&Data_Rsrc);
-
- routine_step = 0;
- for (i = 0;i!=1024;i++)
- {
- N_Cel_Kill(i); //kill plane info
- S1_X[i] = GetRandom(0,640*32)-640*16; //make random points
- S1_Y[i] = GetRandom(0,480*32)-480*16;
- S1_D[i] = GetRandom(1,255);
- }
-
- N_Pict_Effect (131,0,0,3,0,0);
- for (i=0;i!=32;i++)
- {
- Delay(1,&wait);
- N_Pict_Effect (131,0,0,3,1,0);
- N_Pict_Effect (131,0,0,3,1,0);
- N_Pict_Effect (131,0,0,3,1,0);
- N_Pict_Effect (131,0,0,3,1,0);
- N_Pict_Effect (131,0,0,3,1,0);
- N_Pict_Effect (131,0,0,3,1,0);
- N_Pict_Effect (131,0,0,3,1,0);
- N_Pict_Effect (131,0,0,3,1,0);
- }
- N_Button_Put(0);
-
- do
- {
- Main_Process();
- }
- while (q==false);
- N_Music_Out(90); //fade out
- do
- {
- }
- while (FO_Flag == true);
- ShowMenuBar();
- N_Music_Kill();
- N_Sound_Close(); //close sound channels
- ColorRevert();
-
- }
-
- void Main_Process(void)
- {
- short i,x,y,ii,p = 0,dist,bt;
- long wrk;
- long xx,yy;
- char key;
- Boolean emp;
- Point mp;
-
- N_Cel_Put(950,0x80000000+110,4,356); //panel
-
- Key_Process();
- routine_step++;
- N_Font_Put("\pTHANK YOU FOR DOWNLOADING/",lx,10,14,0,1,800);
- lx-=3;
- if (lx <= -600) lx=640;
-
- if (routine_step<64) //move & put a wood panel
- {
- N_Cel_Put(899,0x80000000+256,212,(short)(routine_step*4-92));
- }
- if (routine_step>=64 && routine_step<192)
- {
- N_Cel_Put(899,0x80000000+256,212,164);
- }
- if (routine_step>=192 && routine_step <300)
- {
- N_Cel_Put(899,0x80000000+256,212,(short)164+((routine_step-192)*5));
- }
-
- if (routine_step < 700) ii = routine_step; //max 700 snows
- else ii = 700;
-
- for (i = 0;i!=ii;i++)
- {
- x = S1_X[i];
- y = S1_Y[i];
-
- wrk = S1_D[i];
- wrk = wrk / 16;
- wrk = 16-wrk;
-
- if (wrk>14) wrk = 15;
-
- N_Cel_3D_Put(i,0x80000000+30+wrk,x,y,320,240,r,S1_D[i]); //put a snow
- dist = S1_D[i] + speed;
- if (dist < 0)
- {
- dist = 512+dist;
- N_Cel_Get(i,&emp,&xx,&x,&y);
- N_Sp_Put(0x80000000+46,x-4,y-4);
-
- S1_X[i] = GetRandom(0,640*32)-640*16;
- S1_Y[i] = GetRandom(0,480*32)-480*16;
- }
-
- if (dist > 255)
- {
- dist = dist -256;
-
- S1_X[i] = GetRandom(0,640*32)-640*16;
- S1_Y[i] = GetRandom(0,480*32)-480*16;
- }
-
-
- S1_D[i] = dist;
- }
- r=r+rs;
- N_Cel_Loop(0,0);
-
- bt=N_Button_Check(0);
-
- if (bt==0) q=true;
- if (bt==1) N_Pict_Draw(131,0,0,(GrafPtr)SP_off,true); //re-draw background
- if (bt==2) speed--;
- if (bt==3) speed++;
- if (bt==4) rs++;
- if (bt==5) rs--;
- }
-
- void Key_Process(void)
- {
- char ky;
-
- ky = N_Key_Get();
- if (kb == false)
- {
- if ((ky & 0x01) !=0)
- {
- speed++;
- N_Button_Push(0,3);
- kb = true;
- }
- if ((ky & 0x02) !=0)
- {
- rs++;
- N_Button_Push(0,4);
- kb = true;
- }
- if ((ky & 0x04) !=0)
- {
- rs--;
- N_Button_Push(0,5);
- kb = true;
- }
- if ((ky & 0x08) !=0)
- {
- speed--;
- N_Button_Push(0,2);
- kb = true;
- }
-
- if ((ky & 0x40) !=0)
- {
- N_Pict_Draw(131,0,0,(GrafPtr)SP_off,true); //re-draw background
- N_Button_Push(0,1);
- kb = true;
- }
- }
- if ((ky & 0x80) !=0)
- {
- N_Button_Push(0,0);
- q = true;
- }
- if (ky==0) kb = 0;
- }
-
- WindowPtr CreateWindow (Str255 name)
- {
- WindowPtr window;
- short centerX,centerY;
- short windowWidth,windowHeight;
-
- window = GetNewWindow (128,nil,(WindowPtr)-1L );
- centerX = (qd.screenBits.bounds.right -qd.screenBits.bounds.left)/2;
- centerY = (qd.screenBits.bounds.bottom -qd.screenBits.bounds.top)/2;
- SetWTitle(window,name);
- MoveWindow(window,NewWindowX=centerX-(WindowSizeX/2),NewWindowY=centerY-(WindowSizeY/2),false);
- SizeWindow(window,WindowSizeX,WindowSizeY,TRUE);
-
- ShowWindow(window);
- SetPort((GrafPtr)window );
- return (WindowPtr)window;
- }
-
-
-